﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HCFramework.Product.Payment.Control
{
    public partial class PaymentMethod : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();

                foreach (ListItem item in radioList.Items)
                {
                    item.Text = M.Common.GetLang(item.Text);
                }
            }
        }

        private void BindList()
        {
            foreach (int value in Enum.GetValues(typeof(E.PaymentMethod)))
            {
                string text = E.Method.GetDisplayName_PaymentMethod((E.PaymentMethod)value);
                radioList.Items.Add(new ListItem(text, value + ""));
            }
            radioList.Items[0].Selected = true;
        }

        public int SelectedMethod
        {
            get
            {
                return int.Parse(radioList.SelectedValue);
            }
            set
            {
                radioList.ClearSelection();
                radioList.SelectedValue = value + "";
            }
        }
    }
}